home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15107 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  62 lines

  1. Path: news.polymtl.ca!news
  2. From: Pierre Ferland <pierre@meca.polymtl.ca>
  3. Newsgroups: comp.lang.c++
  4. Subject: templates and incomplete classes
  5. Date: Wed, 03 Apr 1996 13:23:35 -0500
  6. Organization: Center for Applied Research on Polymers
  7. Message-ID: <3162C227.446B@meca.polymtl.ca>
  8. NNTP-Posting-Host: crasp.meca.polymtl.ca
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 2.01 (X11; I; AIX 2)
  13.  
  14. I have the following templates-related compiling problem:
  15.  
  16. Say that you have a ``List_t<class T>'' template, to handle lists
  17. whatever they are.  The template is declared and defined in a ``list.H''
  18. file:
  19.  
  20.         template <class T> List_t {
  21.                 private:
  22.                         T member_Object;
  23.                 public:
  24.                         List_t();
  25.         };
  26.  
  27. Now, a programmer defines a class which handles lists of itslef,
  28. please do not ask me why:
  29.  
  30.         #include "list.H"
  31.         class Buggy_c {
  32.  
  33.  
  34.                 private:
  35.                         List_t < Buggy_c > member_myOwnList;
  36.  
  37.         };
  38.  
  39. Now depending upon the compiler used, we may or may not have incomplete
  40. type problems.
  41.  
  42.  - AIX's xlC c++ compiler works fine.  (surprising, isn't it ?)
  43.  - SGI's native CC compiler works fine
  44.          (had to release from previous cfront version)
  45.  - gcc (version 2.7.2) shoots an incomplete type error,
  46.         during the instantiation
  47.         of List_t < Buggy_c >, apparently because Buggy_c is an
  48.         incomplete type till  List_t < Buggy_c > is completely
  49.         defined, which obviously will not happen!
  50.  
  51. Does anyone have the smallest idea how I could have the compiler
  52. go through this?
  53.  
  54. From the time I've been using templates on, I always got
  55. either compilation or link or readability problems.
  56. Are these templates really worth the effort or is it another
  57. unusable C++ feature we should forbid for serious
  58. developments ?
  59.  
  60.  
  61.         Pierre Ferland (pierre@.meca.polymtl.ca)
  62.